package com.zhangtai.modules.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhangtai.modules.entity.employee.DimissionEntity;
import com.zhangtai.modules.vo.DimissionEntityVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-07-28 16:29:08
 */
@Mapper
public interface DimissionDao extends BaseMapper<DimissionEntity> {

	@Select(
            "<script>" +
                    "Select dimission.*,info.* from tb_dimission dimission  " +
                    "left join tb_employee_info info  on info.oid = dimission.oid  " +
                    "<where>" +
                        "<if test='hiredate!=null'> and dimission.hiredate = #{hiredate} </if>" +
                        "<if test='code!=null'> and dimission.code = #{code} </if>" +
                        "<if test='name!=null'> and dimission.name = #{name} </if>" +
                        "<if test='jobIds!=null and jobIds.size>0'> and dimission.job_system_id in " +
                        "<foreach item=\"jobId\" index=\"index\" collection=\"jobIds\" open=\"(\" separator=\",\" close=\")\">#{jobId}</foreach>" +
                        "</if>"+
						"<if test='orgIds!=null and orgIds.size>0'> and dimission.org_id in " +
							"<foreach item=\"orgId\" index=\"index\" collection=\"orgIds\" open=\"(\" separator=\",\" close=\")\">#{orgId}</foreach>" +
					"</if>"+
					"<if test='orgIds==null or orgIds.size==0'> and dimission.org_id = null " +

					"</if>"+
                    "</where>" +
            "</script>"
    )
	List<DimissionEntityVo> getDimissionList(@Param(value = "date") Date hiredate,
								 @Param(value = "code") String code,
								 @Param(value = "name") String name,
								 @Param(value = "jobIds") List<Long> jobIds,
								 Page<DimissionEntityVo> page,
									  @Param(value = "orgIds") List<Long> orgIds
			
			);
}
